package com.example.demo.test.executor;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

/**
 * Created by Administrator on 2018/4/15.
 */
@Component
public class Task {


    @Async
    public Future<Long> task1() throws Exception {
        long start = System.currentTimeMillis();
        Thread.sleep(1000);
        long end = System.currentTimeMillis();
        return new AsyncResult<>(end-start);
    }

    @Async
    public Future<Long> task2() throws Exception {
        long start = System.currentTimeMillis();
        Thread.sleep(1000);
        long end = System.currentTimeMillis();
        return new AsyncResult<>(end-start);
    }
    @Async
    public Future<Long> task3() throws Exception {
        long start = System.currentTimeMillis();
        Thread.sleep(1000);
        long end = System.currentTimeMillis();
        return new AsyncResult<>(end-start);
    }

}
